﻿@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="form-group">
    <label for="username">姓名:</label>
    <input type="text" class="form-control" id="username" name="username">
</div>
<div class="form-group">
    <button class="btn" onclick="doLogin()">登录</button>
</div>
@section Scripts{
<script>
    function doLogin(){
        $.post("@Url.Action("DoLogin")",{name:$('#username').val().trim()},function(r){
            if(!r.error)
                window.location.href = "/Home/index";
            else
                alert("失败")
        });
    }
</script>
}